<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    String imgSrc = basePath + "resources/images/noImage.jpg";
    session.setAttribute("imgSrc", imgSrc);
%>
<!DOCTYPE html>
<html style="background-color: #fff;">
<head>
    <%@include file="../../../resources/inc/head.jsp" %>
</head>
<body>
<expect-x:tip tipMessage="标识“*”的选项为必填项，其余为选填项。;请按提示信息填写每一个字段" widthClass="full-width-85"/>

<div class="layui-form common-form" lay-filter="layuiadmin-form-contentFriendlyLink"
     id="layuiadmin-form-contentFriendlyLink"
     style="padding: 20px;">


    <div class="layui-form-item">
        <label class="layui-form-label">商户</label>
        <div class="layui-input-inline">
            <input type="hidden" name="id" value="${merchantPaymentConfig.id}">
            <select name="merchantNo" id="merchantNo" lay-filter="merchantNo" lay-verify="required">
                <option value="">请选择商户</option>
                <c:forEach items="${merchantUsers}" var="merchantUser">
                    <option value="${merchantUser.merchantNo}" ${merchantUser.merchantNo==merchantPaymentConfig.merchantNo?'selected':''}>${merchantUser.company}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <%--<div class="layui-form-item">
        <label class="layui-form-label">应用</label>
        <div class="layui-input-inline">
            <select name="agentNo" id="agentNo" lay-filter="agentNo" lay-verify="required">

            </select>
        </div>
    </div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label">APP_ID</label>
        <div class="layui-input-inline">
            <input type="text" name="appId" lay-verify="required" value="${merchantPaymentConfig.appId}"
                   placeholder="请输入APP_ID" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">MCH_ID</label>
        <div class="layui-input-inline">
            <input type="text" name="mchId"  value="${merchantPaymentConfig.mchId}"
                   placeholder="请输入MCH_ID" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">私钥</label>
        <div class="layui-input-inline">
            <input type="text" name="privateKey"  value="${merchantPaymentConfig.privateKey}"
                   placeholder="请输入私钥" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公钥</label>
        <div class="layui-input-inline">
            <input type="text" name="publicKey"  value="${merchantPaymentConfig.publicKey}"
                   placeholder="请输入公钥" autocomplete="off" class="layui-input">
        </div>
    </div>
    <%--<div class="layui-form-item">--%>
        <%--<label class="layui-form-label">signType</label>--%>
        <%--<div class="layui-input-inline">--%>
            <%--<input type="text" name="signType"  value="${merchantPaymentConfig.signType}"--%>
                   <%--placeholder="请输入signType" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="layui-form-item">--%>
        <%--<label class="layui-form-label">gateUrl</label>--%>
        <%--<div class="layui-input-inline">--%>
            <%--<input type="text" name="gateUrl"  value="${merchantPaymentConfig.gateUrl}"--%>
                   <%--placeholder="请输入gateUrl" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label">支付方式</label>
        <div class="layui-input-inline">
            <select name="payWay" lay-verify="required" autocomplete="off">
                <option value="${merchantPaymentConfig.payWay}">${merchantPaymentConfig.payWay==null?"请选择支付方式":merchantPaymentConfig.payWay}</option>
                <c:forEach items="${systemTypes}" var="systemType">
                    <option value="${systemType.typeName}">${systemType.typeName}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>

<%@include file="../../../resources/inc/footer.jsp" %>

<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$
            , form = layui.form
        var merchantNo=   $("#merchantNo").val();


    })

    function createSubmit() {
        var layer = layui.layer;
        var submitID = 'LAY-submit';
        layui.form.on('submit(' + submitID + ')', function (data) {
            var formData = data.field;
            if (formData.id == "" || formData.id == null) {
                delete formData["id"];
                $.ajax({
                    url: '<%=basePath%>manager/merchantPaymentConfig/create.html',
                    type: "POST",
                    data: formData,
                    dataType: "JSON",
                    success: function (data) {
                        layer.closeAll('loading');
                        if (data.success) {
                            layer.msg("创建成功,1秒后跳转")
                            setTimeout(function () {
                                window.parent.location.reload(); //刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }, 1000);
                        } else {
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            } else {
                $.ajax({
                    url: "<%=basePath%>manager/merchantPaymentConfig/update/" + formData.id + ".html",
                    type: "POST",
                    data: formData,
                    dataType: "JSON",
                    success: function (data) {
                        layer.closeAll('loading');
                        if (data.success) {
                            layer.msg("修改成功,1秒后跳转");
                            setTimeout(function () {
                                window.parent.location.reload(); //刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }, 1000);
                        } else {
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            }
        })
        $("#" + submitID).trigger('click');
    }
</script>
</body>
</html>
